package com.dongdongshop.service.impl;

import com.dongdongshop.mapper.TbAreasMapper;
import com.dongdongshop.mapper.TbCitiesMapper;
import com.dongdongshop.mapper.TbProvincesMapper;
import com.dongdongshop.pojo.*;
import com.dongdongshop.service.ProvincesService;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
@DubboService
public class ProvincesServiceImpl implements ProvincesService {

    @Resource
    private TbProvincesMapper provincesMapper;

    @Resource
    private TbCitiesMapper citiesMapper;

    @Resource
    private TbAreasMapper areasMapper;

    @Override
    public List<TbProvinces> getProvince() {
        return provincesMapper.selectByExample(null);
    }

    @Override
    public List<TbCities> getCity(String id) {
        TbCitiesExample example = new TbCitiesExample();
        TbCitiesExample.Criteria criteria = example.createCriteria();
        criteria.andProvinceidEqualTo(id);
        return citiesMapper.selectByExample(example);
    }

    @Override
    public List<TbAreas> getDistrict(String id) {
        TbAreasExample example = new TbAreasExample();
        TbAreasExample.Criteria criteria = example.createCriteria();
        criteria.andCityidEqualTo(id);
        return areasMapper.selectByExample(example);
    }
}
